#pragma once
#include "Shader.h"
#include "MeshDrawingPolicy.h"
#include "ShaderParameter.h"


//
// DepthOnlyVertexShader
//
class DepthOnlyVertexShader : public Shader
{
public:
	static const ShaderType StaticType;
	virtual const ShaderType* getShaderType() const { return &StaticType; }
	
	static bool ShouldCache(const class Material*) { return true; }
	static Shader* Create() { return new DepthOnlyVertexShader(); }
	static void Define(ShaderDefineMap* defineMap) {}

	virtual bool Init();
	virtual void Set(RenderView* view);
	virtual void SetRenderable(RenderView* view, Renderable* renderable);

private:
	ShaderParameter mWorldViewProjMatrixParam;
};

//
// DepthOnlyPixelShader
//
class DepthOnlyPixelShader : public Shader
{
public:
	static const ShaderType StaticType;
	virtual const ShaderType* getShaderType() const { return &StaticType; }
	
	static bool ShouldCache(const class Material*) { return true; }
	static Shader* Create() { return new DepthOnlyPixelShader(); }
	static void Define(ShaderDefineMap* defineMap) {}
};

//
// DepthDrawingPolicy
//
class DepthDrawingPolicy : public MeshDrawingPolicy
{
public:
	DepthDrawingPolicy(const VertexFactory* vertexFactory, const Material* material);

	bool Compare(const DepthDrawingPolicy& other) const
	{
		DRAWINGPOLICY_COMPARE(mVertexFactory);
		DRAWINGPOLICY_COMPARE(mMaterial);

		DRAWINGPOLICY_COMPARE(mVertexShader);
		DRAWINGPOLICY_COMPARE(mPixelShader);
		return false;
	}

	void DrawShared(BoundShaderStatePtr& boundShaderState);
	void DrawRenderable(RenderView* view, Renderable* renderable);

	BoundShaderStatePtr CreateBoundShaderState();

protected:
	DepthOnlyVertexShader* mVertexShader;
	DepthOnlyPixelShader* mPixelShader;
};
